import { StoreDefinition, defineStore } from "pinia";
interface UserType {
  permission: Array<string>;
  token: string;
  userName: string;
  userId: number;
}
const useUserStore:StoreDefinition<string,UserType> = defineStore({
  id: "user",
  state: (): UserType => {
    return {
      permission: [],
      token: "",
      userName: "",
      userId: 0,
    };
  },
  actions: {
    setUser(userId: number, userName: string) {
      this.userId = userId;
      this.userName = userName;
    },
    setPermission(permission: Array<string>) {
      this.permission = permission;
    },
  },
});
export default useUserStore;
